package com.asen.commons.core.meta.dao;

import com.asen.commons.core.meta.enums.OrderSymbolEnum;

import java.io.Serializable;
import java.util.Objects;

/**
 * 排序项
 *
 * @author ls
 * @version 1.0
 * @date 2024-04-09
 */
public class OrderItem implements Serializable {

    private static final long serialVersionUID = -2454746172690303238L;

    private String fieldName;
    private OrderSymbolEnum symbol;

    public OrderItem() {
    }

    public OrderItem(String fieldName, OrderSymbolEnum symbol) {
        this.fieldName = fieldName;
        this.symbol = symbol;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public OrderSymbolEnum getSymbol() {
        return symbol;
    }

    public void setSymbol(OrderSymbolEnum symbol) {
        this.symbol = symbol;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        OrderItem sortItem = (OrderItem) o;
        return Objects.equals(fieldName, sortItem.fieldName) &&
                symbol == sortItem.symbol;
    }

    @Override
    public int hashCode() {
        return Objects.hash(fieldName, symbol);
    }
}
